using System;
using System.Xml;
using System.Xml.XPath;
using System.Text.RegularExpressions;

using Actions;
using Actions.Security;
using Actions.Connectors;
using Actions.Databases;

namespace Actions.Usecases
{
	public class UCSCommit : BaseUsecase
	{	
		public UCSCommit() : base()
		{}

		protected override void process(ref IConnector c, SecurityAgent sa)
		{
			SecurityModel sm = new SecurityModel();			
			string type = c.getInputParam("type");
			string id = c.getInputParam("id");
			
			if(type != null && type.Length > 0 && Regex.IsMatch(type, sm.regType) &&
				id != null && id.Length > 0 && Regex.IsMatch(id, sm.regId)
				) {
				sm.commit(type, id, ref c);
				_d.DocumentElement.InnerXml += sm.showObjectsByType(type);
			}
			_d.setPrefix("ajax");			
		}
	}
}
